{layout name="../../admin/view/layout/main" /}
<div class="card">
    <div class="card-body">
        <p id="info"></p>
    </div>
</div>
<script>
    var tab = 0;
    var page = 0;
    function fetch(ac, callbak){
        $.post("{:url('xbak/index/backup')}", {ac: ac, tab: tab, page: page, start: '{$start}'}, function (res){
            $('#info').html(res.msg);
            callbak(res);
        });
    }
    function exportData(){
        fetch(2, function (res){
            if (res.next == 1){
                tab = tab + 1;
                page = 0;
                exportData();
            }else if (res.next == 2){
                page = page + 1;
                exportData(); 
            }else if (res.next == 3){
                window.parent.result = res.done;
                window.parent.close();
            }
        })
    }
    function doIt(){
        // 1. 初始化
        fetch(0, function (){
            // 2. 导出数据结构
            fetch(1, function (){
               // 3. 导出数据 
               exportData();
            })
        });
    }
    $(function (){
        doIt();
    })
</script>